package com.ruoyi.web.tdmdata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdmdata.domain.TdmZhongYaoZuFangKu;
import com.ruoyi.web.tdmdata.service.ITdmZhongYaoZuFangKuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中药组方剂Controller
 * 
 * @author ly
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tdmdata/TdmZhongYaoZuFangKu")
public class TdmZhongYaoZuFangKuController extends BaseController
{
    @Autowired
    private ITdmZhongYaoZuFangKuService tdmZhongYaoZuFangKuService;

    /**
     * 查询中药组方剂列表
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmZhongYaoZuFangKu tdmZhongYaoZuFangKu)
    {
        startPage();
        List<TdmZhongYaoZuFangKu> list = tdmZhongYaoZuFangKuService.selectTdmZhongYaoZuFangKuList(tdmZhongYaoZuFangKu);
        return getDataTable(list);
    }

    /**
     * 导出中药组方剂列表
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:export')")
    @Log(title = "中药组方剂", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmZhongYaoZuFangKu tdmZhongYaoZuFangKu)
    {
        List<TdmZhongYaoZuFangKu> list = tdmZhongYaoZuFangKuService.selectTdmZhongYaoZuFangKuList(tdmZhongYaoZuFangKu);
        ExcelUtil<TdmZhongYaoZuFangKu> util = new ExcelUtil<TdmZhongYaoZuFangKu>(TdmZhongYaoZuFangKu.class);
        util.exportExcel(response, list, "中药组方剂数据");
    }

    /**
     * 获取中药组方剂详细信息
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmZhongYaoZuFangKuService.selectTdmZhongYaoZuFangKuById(id));
    }

    /**
     * 新增中药组方剂
     */
    // @PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:add')")
    @Log(title = "中药组方剂", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmZhongYaoZuFangKu tdmZhongYaoZuFangKu)
    {
        return toAjax(tdmZhongYaoZuFangKuService.insertTdmZhongYaoZuFangKu(tdmZhongYaoZuFangKu));
    }

    /**
     * 修改中药组方剂
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:edit')")
    @Log(title = "中药组方剂", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmZhongYaoZuFangKu tdmZhongYaoZuFangKu)
    {
        return toAjax(tdmZhongYaoZuFangKuService.updateTdmZhongYaoZuFangKu(tdmZhongYaoZuFangKu));
    }

    /**
     * 删除中药组方剂
     */
    //@PreAuthorize("@ss.hasPermi('tdmdata:TdmZhongYaoZuFangKu:remove')")
    @Log(title = "中药组方剂", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmZhongYaoZuFangKuService.deleteTdmZhongYaoZuFangKuByIds(ids));
    }
}
